﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BG.Web.Admin.Order.Default" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <script type="text/javascript" src="../Kwan.Base.js"></script>
    <script type="text/javascript" src="Kwan.Order.js"></script>
    <form id="Form2" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="Order" />

        <ext:Store ID="Store1" runat="server" OnRefreshData="RefreshDS" RemoteSort="True">
            <Proxy>
                <ext:PageProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader IDProperty="EntityID">
                    <Fields>
                        <ext:RecordField Name="EntityID" />
						<ext:RecordField Name="CardNO" />
						<ext:RecordField Name="CashPay" />
						<ext:RecordField Name="CheckInDate" />
                        <ext:RecordField Name="CheckInRoomPrice" />
						<ext:RecordField Name="CheckInType" />
						<ext:RecordField Name="Days" />
						<ext:RecordField Name="Deposit" />
						<ext:RecordField Name="DisCount" />
						<ext:RecordField Name="Pid" />
						<ext:RecordField Name="PosPay" />
						<ext:RecordField Name="RoomID" />
						<ext:RecordField Name="Status" />
						<ext:RecordField Name="TotalPrice" />
                        <ext:RecordField Name="RoomClassName" />
                        <ext:RecordField Name="RoomNO" />
                        <ext:RecordField Name="RoomStatus" />
                        <%--<ext:RecordField Name="RoomClassPrice" />
                        <ext:RecordField Name="RoomClassReserve" />
                        <ext:RecordField Name="RoomClassHalfPrice" />
                        <ext:RecordField Name="RoomClassHourPrice" />
                        <ext:RecordField Name="RoomPrice" />
                        <ext:RecordField Name="RoomReserve" />
                        <ext:RecordField Name="RoomHalfPrice" />
                        <ext:RecordField Name="RoomHourPrice" />--%>
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="20" Mode="Raw"/>
            </AutoLoadParams>
            <SortInfo Field="EntityID" Direction="DESC" />
            <Listeners> 
                <LoadException Handler="Ext.MessageBox.alert('系统提示', response.statusText);" />                            
            </Listeners>
        </ext:Store>
        <ext:Viewport runat="server" Layout="Fit">
            <Items>
        <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" Title="ExtGridTitle" ColumnLines="True" AutoExpandColumn="RoomNO" Header="False" Frame="true" Height="500" ColumnWidth=".8" TrackMouseOver="true" StripeRows="true">
            <ColumnModel runat="server">
			    <Columns>
                    <ext:RowNumbererColumn />
                    <ext:Column Header="房间号" DataIndex="RoomNO" Width="80" />
                    <ext:Column Header="房型" DataIndex="RoomClassName" Width="80" />
					<ext:Column Header="预住天数" DataIndex="Days" Width="80" />
                    <ext:Column Header="折扣" DataIndex="DisCount" Width="80" />
                    <ext:Column Header="入住单价" DataIndex="CheckInRoomPrice" Width="80" />
					<ext:Column Header="应收金额" DataIndex="TotalPrice" Width="80" />
					<ext:Column Header="已交押金" DataIndex="Deposit" Width="80" />
                    <ext:Column Header="实收金额" DataIndex="CashPay" Width="80" />
					<ext:DateColumn Header="入住时间" DataIndex="CheckInDate" Width="140" Format="yyyy-MM-dd HH:mm:ss" />
                    <ext:Column Header="账单状态" DataIndex="Status" Width="80">
                        <Renderer Fn="Kwan.prepareOrderStatus" />
                    </ext:Column>
			    </Columns>
            </ColumnModel>
            <TopBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Hidden ID="txtFilter" runat="server" AutoDataBind="true">
                            <Listeners>
                                <Change Handler="Store1.reload();" Delay="30" />
                            </Listeners>
                        </ext:Hidden>
                        <ext:TriggerField ID="txtSearch" runat="server" EmptyText=" 全文搜索.." EnableKeyEvents="true">
                            <Listeners>
                                <TriggerClick Handler="if (index == 1) { #{txtFilter}.setValue(this.getValue()); } if(index == 0) { #{txtSearch}.reset(); #{txtFilter}.setValue(''); this.triggers[0].hide(); }" />
                            </Listeners>
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" HideTrigger="true" Qtip="清空" />
                                <ext:FieldTrigger Icon="Search" Qtip="搜索"/>
                            </Triggers>
                        </ext:TriggerField>
                        <ext:ToolbarFill />
                        <%--<ext:Button ID="BtnDeleteInfo" runat="server" Text="全部禁用" Icon="Delete">
                            <Listeners>
                                <Click Handler="Kwan.CheckDelete(#{GridPanel1}.getRowsValues({selectedOnly:true}));" />
                            </Listeners>
                        </ext:Button>--%>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <SelectionModel>
               <ext:CheckboxSelectionModel runat="server" />                   
            </SelectionModel>
            <LoadMask ShowMask="true" />
            <SaveMask ShowMask="true" />
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="20">
                    <Items>
                        <ext:Label runat="server" Text="每页显示:" />
                        <ext:ToolbarSpacer runat="server" Width="10" />
                        <ext:ComboBox Editable="false" runat="server" Width="80">
                            <Items>
                                <ext:ListItem Text="10" />
                                <ext:ListItem Text="20" />
                                <ext:ListItem Text="50" />
                                <ext:ListItem Text="100" />
                            </Items>
                            <SelectedItem Value="20" />
                            <Listeners>
                                <Select Handler="#{PagingToolBar1}.pageSize = parseInt(this.getValue()); #{PagingToolBar1}.doLoad();" />
                            </Listeners>
                        </ext:ComboBox>
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
            <Listeners>
                <Command Handler="Kwan.CellCommand(this, record, command, rowIndex)" />
                <RowDblClick Handler="Kwan.CellCommand(this, this.store.getAt(rowIndex), 'Edit', rowIndex)" />
            </Listeners>        
        </ext:GridPanel>
        </Items>
        </ext:Viewport>
        <ext:Window ID="EditWindow" runat="server" Icon="Group" Title="编辑数据" Width="450" Height="400" AutoShow="false" Modal="true" Collapsible="true" Maximizable="true" Hidden="true" Layout="Fit" LabelWidth="70">
            <Items>
                <ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Border="false" DeferredRender="false">
                    <Items>
                        <ext:FormPanel ID="EditForm" MonitorValid="true" runat="server" Title="基本信息" Icon="ChartOrganisation" Padding="5" Layout="Form" LabelAlign="Right" LabelWidth="70" MonitorResize="true">
                            <Items>
                                <ext:Hidden ID="txtID" runat="server" />
                                <ext:Hidden ID="hdnDeposit" runat="server" />
                                <%--<ext:FieldSet runat="server" Padding="10" Layout="form">
                                <Items>--%>
                                <ext:Hidden ID="txtPrice" runat="server" />
                                <ext:Hidden ID="txtDisCount" runat="server" />
                                <ext:Container runat="server" Layout="Column" Height="20" AnchorHorizontal="99%">
                                <Items>
                                <ext:Container runat="server" LabelAlign="Left" Layout="Form" ColumnWidth=".5">
                                <Items>
                                    <ext:Label ID="txtCardNo" ReadOnly="true" FieldLabel="卡号" AnchorHorizontal="98%" runat="server" AllowBlank="false" />
                                </Items>
                                </ext:Container>
                                <ext:Container runat="server" LabelAlign="Left" Layout="Form" ColumnWidth=".5">
                                <Items>
                                    <ext:Label ID="txtEndDate" FieldLabel="上次结账日期" AnchorHorizontal="98%" runat="server" ReadOnly="true" />
                                </Items>
                                </ext:Container>
                                </Items>
                                </ext:Container>
                                <%--</Items>
                                </ext:FieldSet>--%>
                                <ext:BoxComponent runat="server" Cls="divider" />
                                <ext:DropDownField ID="txtRoomID" runat="server" FieldLabel="选择房间" Editable="false" AnchorHorizontal="90%" TriggerIcon="Search" Mode="ValueText" AllowBlank="False">
                                    <Component>
                                        <ext:TreePanel ID="TreePanel1" runat="server" Icon="Accept" Height="300" Shadow="None" UseArrows="true" AutoScroll="true" Animate="true" EnableDD="true" ContainerScroll="true" RootVisible="false">
                                        <Root>
                                            <ext:AsyncTreeNode Text="Examples" NodeID="root" Expanded="true" Checked="False" />
                                        </Root>
                                        <Loader>
                                            <ext:PageTreeLoader RequestMethod="POST" OnNodeLoad="GetExamplesNodes" PreloadChildren="true">
                                            </ext:PageTreeLoader>
                                        </Loader>

                                        <SelectionSubmitConfig Encode="true" />
                                        <Listeners>
                                            <ContextMenu Fn="Kwan.showMenu" StopEvent="true" />
                                            <Click Handler="this.dropDownField.setValue(node.id,node.parentNode.text+' - '+node.attributes.text,true);Order.SetFormChange(node.id);" />
                                        </Listeners>
                                    </ext:TreePanel>
                                    </Component>
                                    <Listeners>
                                        <Expand Handler="this.component.getRootNode().expand(true);" Single="true" Delay="10" />
                                    </Listeners>
                                </ext:DropDownField>

								<ext:TextField ID="txtDeposit" FieldLabel="应收押金" AnchorHorizontal="90%" runat="server" />
								<ext:TextField ID="txtDays" FieldLabel="入住天数" AnchorHorizontal="90%" runat="server">
                                    <Listeners>
                                        <Change Handler="Order.SetFormChange(#{txtRoomID}.getValue());" />
                                    </Listeners>
                                </ext:TextField>
								<ext:TextField ID="txtTotalPrice" FieldLabel="总金额" AnchorHorizontal="90%" runat="server" ReadOnly="True" />
                                <ext:ComboBox ID="txtStatus" Editable="false" FieldLabel="状态" EmptyText="请选择..." AnchorHorizontal="90%" AllowBlank="false" runat="server">
                                    <Items>
                                        <ext:ListItem Text="已禁用" Value="0" />
                                        <ext:ListItem Text="未入住" Value="1" />
                                        <ext:ListItem Text="登记入住" Value="2" />
                                        <ext:ListItem Text="已退房" Value="3" />
                                    </Items>
                                    <SelectedItem Value="2" />
                                </ext:ComboBox>
								<ext:DateField ID="txtCheckInDate" FieldLabel="入住时间" Width="150" runat="server" Disabled="true" Format="yyyy-MM-dd HH:mm:ss"/>

                                <ext:CheckboxGroup runat="server" ColumnsNumber="2" FieldLabel="选项" AnchorHorizontal="50%">
                                    <Items>
                                        <ext:Checkbox ID="txtIsDisCount" BoxLabel="享受优惠" runat="server">
                                            <Listeners>
                                                <Check Handler="Order.SetFormChange(#{txtRoomID}.getValue());" />
                                            </Listeners>
                                        </ext:Checkbox>
                                    </Items>
                                </ext:CheckboxGroup>
                            </Items>
                            <Listeners>
                                <ClientValidation Handler="#{SaveButton}.setDisabled(!valid);" />
                            </Listeners>
                        </ext:FormPanel>
                    </Items>
                </ext:TabPanel>
            </Items>
            <Buttons>
                <ext:Button ID="SaveButton" runat="server" Text="保存" Icon="Disk">
                    <DirectEvents>
                        <Click OnEvent="SaveEditWindow" Failure="Ext.MessageBox.alert('系统提示', response.statusText);">
                            <EventMask Target="CustomTarget" CustomTarget="={#{EditWindow}.body}" ShowMask="True" />
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="CancelButton" runat="server" Text="返回" Icon="Cancel">
                    <Listeners>
                        <Click Handler="#{EditWindow}.hide(null);" />
                    </Listeners>
                </ext:Button>
            </Buttons>
            <Listeners>
                <Show Handler="Ext.net.Mask.hide();" Delay="2000" />
            </Listeners>
        </ext:Window>
    </form>
</body>
</html>